This is a rather simple project that demonstrates how to use the scrolling and tiling routines. The code is very similar to the code used for non-scrolling SpriteWorlds, and is not really any harder to set up. Use the numeric keypad or the arrow keys to move your ball around on the screen.
This program demonstrates some of the special effects that can be accomplished when using the tiling routines, such as having tiles that change frames (the diamond and wall tiles), and tiles that appear in front of your sprites. If you scroll down far enough, you can find the tiles that appear above your sprite. Move under the bridge to get to the other side, where your sprite can move under the "wire" tiles. It's a pretty neat effect, and shows how you can make games that have pseudo-3D landscapes by having some tiles appear above your sprites.
This demo is limited to 30fps so that the sprite isn't too hard to control on faster Macs. If you want to see how fast it can really go, try setting kMaxFPS (a #defined value at the beginning of Scrolling Demo.c) to 0, which tells SpriteWorld to let the animation run as fast as it can. Also, for maximum speed, try running in either 256 colors or in B&W.
This demo is actually a bare-bones version of a game I'm currently working on. Look for the title "Diamond Digger" sometime in the year 2000.
* Update *
With the release of SpriteWorld 2.1, I've added a new feature - a "meter" that measures how many diamonds you've collected. The purpose of this meter was to demonstrate how to add a sprite to the animation that must remain at a fixed position on the screen, even while scrolling. This is first accomplished by making a MoveProc that moves the sprite to the current visScrollRect location plus wherever you want the sprite to appear on the screen:
This will ensure that the Sprite is moved after the visScrollRect is moved. If it were moved first, the Sprite would always be moving to its position a frame late, which would make it look like it's "chasing" the visScrollRect.
There is yet another trick this program now demonstrates, and that is how to modify a sprite's image and mask while the program is running. To see how this is done, take a look at the UpdateDiamondMeter function. Notice that the sprite's needsToBeDrawn flag is set to true whenever the sprite's image is changed. Keep in mind that this is an idle sprite, only moving whenever the screen scrolls. (Keep in mind that the sprite does move when the screen scrolls, even though it appears to remain in a fixed position on the screen.) Although the screen usually scrolls whenever you pick up a diamond, there is an instance in the demo where you could pick up a diamond without the screen scrolling, and the meter would be updated offscreen, but the sprite would not be redrawn on the screen, since SpriteWorld thinks the sprite is idle and hasn't changed. This is why we must tell SpriteWorld that is has changed, by setting the needsToBeDrawn flag to true.
In general, it's a good idea to set the needsToBeDrawn flag to true whenever you make a change to a sprite that SpriteWorld doesn't know about, even if you think the flag will be set to true by SpriteWorld anyway, since sometimes it might not be. One example would be if you set a MoveTime for a sprite - the sprite may move some frames and not others. When it doesn't move, SpriteWorld will try to save time by not drawing it. And if you'd make a change to the sprite that SpriteWorld didn't know about, and you didn't set the needsToBeDrawn flag to true, the sprite won't get updated.
For more information about changing a Sprite's image and pixelMask, see the sections "Modifying a Sprite's image" and "Modifying a Sprite's pixelMask" in the SpriteWorld Tips and Tricks file.
Yet Another Update
There is now also a number Sprite in the upper-right corner of the screen that displays the current number of diamonds you've collected. This was to demonstrate how to use the routines in SWStats.c, and to show how easy it is to add numbers to your game, either as part of the animation itself, or as part of a separate display. Thanks to Ian Baxter for the great number artwork!
In addition, there are also now particle effects when you run over a diamond. You can turn these off using the kDoParticleExplosion definition in Scrolling Demo.c. You may notice a pause on older computers when you first run over a diamond. This is because each diamond has over 1000 particles, and for each particle, there are several floating point -> fixed point conversions. (Any conversion from floating point to integer is going to be slow, regardless of whether you have an FPU or not.) See DoParticleExplosionForTile to see how the particle explosions are created.
If you are creating a game with similar particle explosions, and you wish to avoid this delay, you could always pre-compute the explosion velocities for each particle, and store the fixed-point results in a lookup table.